﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyModels.Models
{
    /// <summary>
    /// 用户信息表
    /// </summary>
    public class SysUserInfo : RootEntityTKey<long>
    {
        public SysUserInfo() { }
        public SysUserInfo(string name,string pwd)
        {
            LoginName = name;
            LoginPwd = pwd;
            RealName = name;
            Status = 0;
            CreateTime = DateTime.Now;
            ErrorCount = 0;
            Name = "";
        }
        /// <summary>
        /// 登录账户
        /// </summary>
        public string? LoginName { get; set; }

        /// <summary>
        /// 登录密码
        /// </summary>
        public string? LoginPwd { get; set; }

        /// <summary>
        /// 真是姓名
        /// </summary>
        public string? RealName { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// 部门Id
        /// </summary>
        public long? DepartmentId { get; set; } = -1;

        /// <summary>
        /// 备注
        /// </summary>
        [SugarColumn(Length = 2000)]
        public string? Remark { get; set; }

        /// <summary>
        /// 关键业务修改时间
        /// </summary>
        public DateTime CriticalModifyTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 最后异常时间
        /// </summary>
        public DateTime LastErrorTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 错误次数
        /// </summary>
        public int ErrorCount { get; set; }

        /// <summary>
        /// 登录账户
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 性别
        /// </summary>
        public int? Sex { get; set; }

        /// <summary>
        /// 年龄
        /// </summary>
        public int? Age { get; set; }

        /// <summary>
        /// 生日
        /// </summary>
        public DateTime? Birth { get; set; }

        /// <summary>
        /// 地址
        /// </summary>
        public string? Address { get; set; }

        [SugarColumn(DefaultValue = "1")]
        public bool Enabled { get; set; } = true;

        // 下面是忽略字段 在数据库中不存在
        [SugarColumn(IsIgnore = true)]
        public List<string> RoleNames { get; set; }

        /// <summary>
        /// 父节点id集合
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<long> Dids { get; set; }

        [SugarColumn(IsIgnore = true)]
        public string DepartmentName { get; set; }

        [SugarColumn(IsIgnore = true)]
        public List<long> RIDs { get; set; }
    }
}
